<template>
    <div class="data-info">
        <el-card class="box-card">
            <div slot="header" class="clearfix">
                <div class="el-page-header">
                    <div class="el-page-header__left" @click="crud.goBack()">
                        <i class="el-icon-back"></i>
                        <div class="el-page-header__title">返回</div>
                    </div>
                    <div class="el-page-header__content" style="font-size: 14px;">节点详情</div>
                </div>
            </div>
            <template>
                <el-tabs v-model="activeName" @tab-click="handleClick">
                    <el-tab-pane label="状态" name="1" >
                        <status-info :agent-info="agentInfo" />
                    </el-tab-pane>
                    <el-tab-pane label="配置" name="2">
                        <conf-info :agentInfo="agentInfo" />
                    </el-tab-pane>
                    <el-tab-pane label="任务列表" name="3">
                        <running-task :agentInfo="agentInfo" />
                    </el-tab-pane>
                    <el-tab-pane label="升级记录" name="4">
                         <upgrade-log :agentInfo="agentInfo" v-if="activeName === '4'" />
                    </el-tab-pane>
                    <el-tab-pane label="运行日志" name="5">
                        <server-log ref="serverLog" :agentInfo="agentInfo" v-if="activeName === '5'" />
                    </el-tab-pane>
                    <el-tab-pane label="操作日志" name="6">
                        <opt-log :agentInfo="agentInfo" v-if="activeName === '6'"/>
                    </el-tab-pane>
                </el-tabs>
            </template>
        </el-card>
    </div>
</template>

<script>
    import CRUD, {crud} from '@crud/crud'
    import statusInfo from '../components/statusInfo'
    import confInfo from '../components/confInfo'
    import runningTask from '../components/runningTask'
    import serverLog from '../components/serverLog'
    import optLog from '../components/optLog'
    import upgradeLog from '../components/upgradeLog'

    export default {
        name: 'dispatchDetail',
        components: {statusInfo, confInfo, runningTask, serverLog, optLog, upgradeLog},
        mixins: [crud()],
        props: {
            agentInfo: Object,
            default: null
        },
        data() {
            return {
                activeName: "1",
            }
        },
        created() {

        },
        methods: {
            handleClick(tab, event) {
                if(this.activeName != '5'){
                    this.$refs.serverLog.clearReflash();
                }
            }
        }
    }
</script>
